package com.shidaimanong.demo.reflect;

/**
 * 学编程，关注：十代码农
 * 抖音、快手、B站、西瓜视频、今日头条
 */
public class ReflectDemo3 {
    public static void main(String[] args) {
        try {
            User user = (User) Class.forName("com.shidaimanong.demo.reflect.User").newInstance();
            System.out.println(user.getAge());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class User {
    private Integer age = 18;

    private void setAge(Integer age) {
        this.age = age;
    }

    public int getAge() {
        return age;
    }
}